package com.ss.android.article.browser.download;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull;

import com.a.a.NightMode;
import com.a.a.u;
import com.ss.android.article.browser.download.internal.DownloadState;
import com.ss.android.article.browser.download.internal.DownloadDBHelper;
import com.ss.android.article.browser.download.internal.DownloadTask;

import java.util.ArrayList;
import java.util.List;

public final class l implements NightMode {
    private final DownloadTaskManager a;

    public l(DownloadTaskManager arg1) {
        this.a = arg1;
    }

    public final void f(@NonNull Object arg14) {
        int v12 = 3;
        int v11 = 2;
        DownloadDBHelper v0 = DownloadTaskManager.a(this.a);
        ArrayList v8 = new ArrayList();
        SQLiteDatabase v0_1 = v0.getReadableDatabase();
        String[] v2 = new String[9];
        v2[0] = "url";
        v2[1] = "downloadState";
        v2[v11] = "file_dir";
        v2[v12] = "filename";
        v2[4] = "title";
        v2[5] = "thumbnail";
        v2[6] = "finishedSize";
        v2[7] = "totalSize";
        v2[8] = "create_time";
        Cursor v6 = v0_1.query("download", v2, "downloadState=\'FINISHED\'", null, null, null, "_id desc");
        if (v6 != null) {
            while (v6.moveToNext()) {
                DownloadTask v0_2 = new DownloadTask(v6.getString(0), v6.getString(v11), v6.getString(v12), v6.getString(4), v6.getString(5));
                v0_2.downloadState = DownloadState.valueOf(v6.getString(1));
                v0_2.finishedSize = ((long) v6.getInt(6));
                v0_2.totalSize = ((long) v6.getInt(7));
                v0_2.createTime = v6.getLong(8);
                ((List) v8).add(v0_2);
            }

            v6.close();
        }

        ((u) arg14).onItem(v8);
    }
}

